<%-- 
    Document   : addPrizeType
    Created on : 13-08-2014, 22:30:05
    Author     : NGOCLINH-PC
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="Data.Member"%>
<%@page import="Data.Event"%>
<%@page import="Data.PrizeType"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Data.Prize"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<div class="tablemember">
    <form action="../PrizePR" method="post" name="formmember">
        <h2 style="padding: 10px; color: #999;">Management Prize</h2>
        <hr />
        <table width="100%" border="0" align="center" cellpadding="14" cellspacing="14">
            <%
                if (request.getParameter("EprizeID") != null) {
                    Prize ct = new Prize();
                    int payID = Integer.parseInt(request.getParameter("EprizeID"));
                    ArrayList<Prize> a = ct.PselectByID(payID);
                    if (a.size() > 0) {
                        for (int i = 0; i < a.size(); i++) {
                            Prize pay = a.get(i);
                            out.print("<input type='hidden' readonly name='txtPrizeID' id='txtPrizeID' value='" + pay.getPrizeID() + "' />");

            %>
            <tr>
                <td width='10%'>Prize Type</td>
                <td width='50%'><label for='txtPrizeTypeID'></label>
                    <select name="txtPrizeTypeID"   class="txtPrizeTypeID">
                        <%
                            String strT = "";
                            PrizeType pt = new PrizeType();
                            ArrayList<PrizeType> lspt = pt.PTselect();
                            for (int e = 0; e < lspt.size(); e++) {
                                PrizeType me = lspt.get(e);
                                if (pay.getPrizeTypeID() == me.getPrizeTypeID()) {
                                    strT += "<option value='" + me.getPrizeTypeID() + "' selected='selected'>" + me.getPrizeTypeName() + "</option>";
                                } else {
                                    strT += "<option value='" + me.getPrizeTypeID() + "'>" + me.getPrizeTypeName() + "</option>";
                                }
                            }
                            out.print(strT);
                        %>

                    </select>


            </tr>

            <tr>
                <td width="10%">Event</td>
                <td width="57%"><label for="txtdanhmuc"></label>
                    <select style="min-width: 200px" name='txtEvent' class='txtEvent'>
                        <%
                            String strEvent = "";
                            Date d = new Date();
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                            String hientai = sdf.format(d.getTime());
                            Event event = new Event();
                            ArrayList<Event> ArEvent = event.ESelectbyQuery("SELECT * FROM Event Where Status=1");
                            if (ArEvent.size() > 0) {
                                for (int e = 0; e < ArEvent.size(); e++) {
                                    Event lsEvent = ArEvent.get(e);

                                    String timeevent = lsEvent.getTimeEvent();
                                    if (timeevent.compareTo(hientai) < 0) {
                                        int id = lsEvent.getEventID();
                                        ArrayList<Event> aEvt = event.ESelectByID(id);
                                        if (aEvt.size() > 0) {
                                            for (int jk = 0; jk < aEvt.size(); jk++) {
                                                Event lsev1 = aEvt.get(jk);
                                                if (pay.getEventID() == lsev1.getEventID()) {
                                                    strEvent += "<option value='" + lsev1.getEventID() + "' selected='selected'>" + lsev1.getEventName() + "</option>";
                                                } else {
                                                    strEvent += "<option value='" + lsev1.getEventID() + "'>" + lsev1.getEventName() + "</option>";
                                                }
                                            }
                                        }
                                    }
                                }
                                out.print(strEvent);
                            }
                        %>
                    </select>
            </tr>
            <tr>
                <td width="10%">Member</td>
                <td width="57%"><label for="txtdanhmuc"></label>
                    <select style="min-width: 200px" name='txtMember' class='txtMember'>
                        <%
                            String str = "";
                            Member m = new Member();
                            ArrayList<Member> mb = m.CustomerSelect();
                            for (int u = 0; u < mb.size(); u++) {
                                Member ma = mb.get(u);
                                if (pay.getMemberID() == ma.getMemberID()) {
                                    str += "<option value='" + ma.getMemberID() + "' selected='selected'>" + ma.getMemberName() + "</option>";
                                } else {
                                    str += "<option value='" + ma.getMemberID() + "'>" + ma.getMemberName() + "</option>";
                                }
                            }
                            out.print(str);
                        %>
                    </select>

            </tr>
            <tr>
                <td width="10%">Detail Prize</td>
                <td width="57%"><label for="txtdanhmuc"></label>
                    <% out.print("<textarea name='txtPrizeName' class='ckeditor' id='txtPrizeName' cols='45' rows='5'>" + pay.getPrizeName() + "</textarea>");%>
            </tr>
            <tr>
                <td>Status:</td>
                <%
                    if (pay.getStatus() == 1) {
                        out.print("<td><input type='radio' name='radio1' id='rdtrangthai' value='1' checked />");
                        out.print(" Show ");
                        out.print("<input type='radio' name='radio1' id='rdtrangthai' value='0' />");
                        out.print("Hidden</td>");
                    } else {
                        out.print("<td><input type='radio' name='radio1' id='rdtrangthai' value='1' />");
                        out.print(" Show ");
                        out.print("<input type='radio' name='radio1' id='rdtrangthai' value='0' checked />");
                        out.print("Hidden</td>");
                    }
                %>
            </tr>
            <tr align="">
                <td></td>
                <td ><input type="submit" name="btnsubmit" id="btnsubmit" value="Submit" />
                </td>
            </tr>
            <%
                    }
                }
            } else {
            %>
            <tr>
                <td width='10%'>Prize Type</td>
                <td width='50%'><label for='txtPrizeTypeID'></label>
                    <select style="min-width: 200px" name='txtPrizeTypeID' class='txtPrizeTypeID'>
                        <option value="1">--All--</option>
                        <%
                            PrizeType PrizeType = new PrizeType();
                            ArrayList<PrizeType> ArPrizeType = PrizeType.PTselectByStatus();
                            if (ArPrizeType.size() > 0) {
                                for (int i = 0; i < ArPrizeType.size(); i++) {
                                    PrizeType lsPrizeType = ArPrizeType.get(i);
                                    out.print("<option value='" + lsPrizeType.getPrizeTypeID() + "'>" + lsPrizeType.getPrizeTypeName() + "</option>");
                                }
                            }
                        %>
                    </select>

            </tr>
            <tr>
                <td width="10%">Event</td>
                <td width="57%"><label for="txtdanhmuc"></label>
                    <select style="min-width: 200px" name='txtEvent' class='txtEvent'>
                        <option value="1">--All--</option>
                        <%
                            Date d = new Date();
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                            String hientai = sdf.format(d.getTime());
                            Event event = new Event();
                            ArrayList<Event> ArEvent = event.ESelectbyQuery("SELECT * FROM Event Where Status=1");
                            if (ArEvent.size() > 0) {
                                for (int i = 0; i < ArEvent.size(); i++) {
                                    Event lsEvent = ArEvent.get(i);

                                    String timeevent = lsEvent.getTimeEvent();
                                    if (timeevent.compareTo(hientai) < 0) {
                                        int id = lsEvent.getEventID();
                                        ArrayList<Event> aEvt = event.ESelectByID(id);
                                        if (aEvt.size() > 0) {
                                            for (int jk = 0; jk < aEvt.size(); jk++) {
                                                Event lsev1 = aEvt.get(jk);

                                                out.print("<option value='" + lsev1.getEventID() + "'>" + lsev1.getEventName() + "</option>");
                                            }
                                        }
                                    }
                                }
                            }
                        %>
                    </select>
                </td>
            </tr>
            <tr>
                <td width="10%">Member</td>
                <td width="57%"><label for="txtMember"></label>
                    <select style="min-width: 200px" name='txtMember' class='txtMember'>
                        <option value="1">--All--</option>
                        <%
                            Member member = new Member();
                            ArrayList<Member> ArMember = member.CustomerSelect();
                            if (ArMember.size() > 0) {
                                for (int i = 0; i < ArMember.size(); i++) {
                                    Member lsMem = ArMember.get(i);
                                    out.print("<option value='" + lsMem.getMemberID() + "'>" + lsMem.getMemberName() + "</option>");
                                }
                            }
                        %>
                    </select>

            </tr>
            <tr>
                <td width="10%">Detail Prize</td>
                <td width="57%"><label for="txtdanhmuc"></label>
                    <textarea name='txtPrizeName' class='ckeditor' id='txtPrizeName' cols='45' rows='5'></textarea>
            </tr>
            <tr>
                <td>Status:</td>
                <td><input type="radio" name="radio1" id="rdtrangthai" value="1" checked />
                    Show 
                    <input type="radio" name="radio1" id="rdtrangthai" value="0"  checked />
                    Hidden</td>
            </tr>
            <tr align="">
                <td></td>
                <td ><input type="submit" name="btnsubmit" id="btnsubmit" value="Submit" />
                </td>
            </tr>

            <% }%>    
        </table>
    </form>
</div>
